package org.eclipse.iota.xtext.converter;

import java.math.BigInteger;

import org.eclipse.xtext.common.services.DefaultTerminalConverters;
import org.eclipse.xtext.conversion.IValueConverter;
import org.eclipse.xtext.conversion.ValueConverter;
import org.eclipse.xtext.conversion.impl.AbstractToStringConverter;
import org.eclipse.xtext.parsetree.AbstractNode;


public class IotaValueConverterService extends DefaultTerminalConverters {
	
	@ValueConverter(rule = "BOOL")
	public IValueConverter<Boolean> BOOL() {
		return new AbstractToStringConverter<Boolean>() {
			@Override
			public Boolean internalToValue(String string, AbstractNode node) {
				return Boolean.valueOf(string);
			}
		};
	}
	
	@ValueConverter(rule = "BIG_INT")
	public IValueConverter<BigInteger> BIG_INT() {
		return new AbstractToStringConverter<BigInteger>() {
			@Override
			public BigInteger internalToValue(String string, AbstractNode node) {
				return new BigInteger(string);
			}
		};
	}
	
}
